
package com.mfangsoft.zhuangjialong.common.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SerializeUtil {

public static  byte[]  serialize(Object obj) throws IOException{
	
	 ByteArrayOutputStream bo=new ByteArrayOutputStream();
	         ObjectOutputStream oo=new ObjectOutputStream(bo);
	         oo.writeObject(obj);
	         byte[] bytes=bo.toByteArray();
	         bo.close();
	         oo.close();
	         return bytes;
	}
	
public static  Object  unserialize(byte[] bytes) throws IOException, ClassNotFoundException{
		
		 ByteArrayInputStream in=new ByteArrayInputStream(bytes);
		          ObjectInputStream sIn=new ObjectInputStream(in);
        return sIn.readObject();
		}

}
